package com.share.api;

import com.share.common.core.domain.R;
import com.share.common.security.annotation.InnerAuth;
import com.share.rule.domain.FeeRule;
import com.share.rule.domain.FeeRuleRequestForm;
import com.share.rule.domain.FeeRuleResponseVo;
import com.share.service.FeeRuleService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/feeRuleApi")
public class FeeRuleApiController {


    @Autowired
    private FeeRuleService feeRuleService;


    /**
     * 计算订单费用
     *
     * @param feeRuleRequestForm
     * @return
     */
    @Operation(summary = "计算订单费用")
    @PostMapping("/calculateOrderFee")
    public R<FeeRuleResponseVo> calculateOrderFee(@RequestBody FeeRuleRequestForm feeRuleRequestForm) {
        return R.ok(feeRuleService.calculateOrderFee(feeRuleRequestForm));
    }


    /**
     * 批量获取全部费用规则
     *
     * @param feeRuleIds
     * @return
     */
    @Operation(summary = "批量获取全部费用规则")
    @PostMapping("/getFeeRuleList")
    public R<List<FeeRule>> getFeeRuleList(@RequestBody List<Long> feeRuleIds) {
        List<FeeRule> feeRules = feeRuleService.listByIds(feeRuleIds);
        return R.ok(feeRules);
    }


    /**
     * 获取费用规则详细信息
     * @param id
     * @return
     */
    @Operation(summary = "获取费用规则详细信息")
    @GetMapping(value = "/getFeeRule/{id}")
    public R<FeeRule> getFeeRule(@PathVariable("id") Long id) {
        FeeRule feeRule = feeRuleService.getById(id);
        System.out.println("feeRule"+feeRule);
        return R.ok(feeRule);
    }



}
